package com.gettec.lims.client.util;

import com.extjs.gxt.ui.client.binding.Converter;
import com.extjs.gxt.ui.client.widget.form.Field;
import com.extjs.gxt.ui.client.widget.form.Radio;
import com.extjs.gxt.ui.client.widget.form.RadioGroup;

public class RadioGroupConverter extends Converter{
	RadioGroup group;
	public RadioGroupConverter(RadioGroup group) {
	   this.group = group;
	}
	@Override
	public Object convertFieldValue(Object value) {
	   System.out.println(((Radio)value).getValueAttribute());
	   return ((Radio)value).getValueAttribute();
	}
	@Override
	public Object convertModelValue(Object value) {
	   for (Field<?> rad: group.getAll())
	    if (((Radio)rad).getValueAttribute() == value)
	    return rad;

	   return null;
	}
	}
